New Test for IQueryPlanning and filtering with string collection#4202
New Test for IQueryPlanning and filtering with string collection#4202a-shtifanov-laya wants to merge 1 commit intoJasperFx:masterfrom
Conversation
…ng) contains filtering by string colleciton
|
|
||
| public class IssuesByTitles: ICompiledListQuery<Issue>, IQueryPlanning | ||
| { | ||
| [Marten.Events.CodeGeneration.MartenIgnore] |
There was a problem hiding this comment.
i'm not sure if this should be used or not. without this attribute it throws an exception because it tries to use undrying type (string) as document type
System.ArgumentOutOfRangeException: This type cannot be used as a Marten document (Parameter 'documentType')
at Marten.Schema.DocumentMapping..ctor(Type documentType, StoreOptions storeOptions) in //src/Marten/Schema/DocumentMapping.cs:line 116
at Marten.Schema.DocumentMapping`1..ctor(StoreOptions storeOptions) in //src/Marten/Schema/DocumentMapping.cs:line 843
....
| void IQueryPlanning.SetUniqueValuesForQueryPlanning() | ||
| { | ||
| Status = "status"; | ||
| Titles = ["title"]; |
There was a problem hiding this comment.
it seems that the issue is in code generation when IQueryPlanning is used. It produces valid sql and parameters, but it does not use the value from the _query for this array param. Maybe due to MartenIgnore.
public override void ConfigureCommand(Weasel.Postgresql.ICommandBuilder builder, Marten.Internal.IMartenSession session)
{
var parameters1 = builder.AppendWithParameters(@"select d.data from public.mt_doc_issue as d where (d.data ->> 'Status' = ^ and d.data ->> 'Title' = ANY(^));", '^');
parameters1[0].NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Text;
parameters1[0].Value = _query.Status;
parameters1[1].Value = new string[]{"title"}; // <---- here is the constant instead of _query.Titles
parameters1[1].NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Varchar;
}if i edit it manually to _query.Titles it returns valid results
|
@a-shtifanov-laya I'm starting to look at this now |
…anning Array-typed properties (string[], Guid[], int[], etc.) on compiled query classes were incorrectly classified as Include members because string[] implements IList<string>. This caused IsOneOf() parameters to be hardcoded with template values instead of reading from the query instance. The fix has four parts: 1. CompiledQueryPlan.sortMembers: check for array types with known element-type finders BEFORE the IList<> check 2. ArrayParameterFinder<T>: new finder that matches T[] types and provides unique array values for query planning 3. QueryMember.tryToFind: use structural array comparison instead of reference equality when matching parameter values 4. ParameterUsage.generateSimpleCode: emit correct composite NpgsqlDbType (Array | ElementType) for array parameters Closes #4202 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
No description provided.